
function go(link)
{
   window.location.href = basedomain+link;
}



//------------------------------------------------------------------------------



function enableButton(id)
{
   $('#'+id).removeClass('btnDisabled').addClass('btnEnabled');
   
   $('#'+id).attr('disabled','');
}


function disableButton(id)
{
   $('#'+id).removeClass('btnEnabled').addClass('btnDisabled');
   
   $('#'+id).attr('disabled','disabled');
}


//------------------------------------------------------------------------------

function removeAttachment(cfc, filename) // "_CMTID_f_COUNTER_"
{
   var dvId = '#dvFAttFile'+cfc;

   $.post(basedomain+'/attachments', {what:'removeattachment', ids:cfc, fn: filename}, function(data)
   {
//      if(data == 'ok, '+filename)
      {
         $(dvId).fadeOut('fast');
         $(dvId).remove();
      }
//      else
      {
//         alert("Something nasty happened.\nTry again later.\n"+data);
      }
   }, 'text');
}

//------------------------------------------------------------------------------


function tinymceInit(elems)
{
      $(elems).tinymce({
         script_url : basedomain+'/jsx/tmce/tiny_mce.js',

         theme : 'advanced',
         skin : 'o2k7',
         skin_variant : 'black',
         language : 'ru',

         theme_advanced_buttons1 : 'bold,italic,|,link,unlink,|,undo,redo,|,cleanup,code',
         theme_advanced_buttons2 : '',
         theme_advanced_buttons3 : '',
         theme_advanced_buttons4 : '',
         theme_advanced_toolbar_location : 'top',
         theme_advanced_toolbar_align : 'left',
         theme_advanced_statusbar_location : 'bottom',
         theme_advanced_resizing : true,
         forced_root_block : false,

         setup : function(ed)
                  {
                     ed.onPostProcess.add(function(ed, o)
                     {
                        if(o.get)
                        {
                           o.content = o.content.replace("</p>\n<p>", '<br>');
                           o.content = o.content.replace("</div>\n<div>", '<br>');
                           
                           //o.content = o.content.replace("</p>\r<p>", '<br>');
                           //o.content = o.content.replace("</div>\r<div>", '<br>');
                           
                           o.content = o.content.replace("</p><p>", '<br>');
                           o.content = o.content.replace("</div><div>", '<br>');
                           
                           o.content = o.content.replace(/<(span|font)([^>]*)>/g, '');
                           o.content = o.content.replace(/<\/(span|font)>/g, '');

                           o.content = o.content.replace(' -> ', '&rarr;');
                           o.content = o.content.replace(' <- ', '&larr;');
                           
                           o.content = o.content.replace(' - ', ' &ndash; ');
                           o.content = o.content.replace("\n- ", '\n&ndash; ');
                           o.content = o.content.replace('>- ', '>&ndash; ');
                        }
                     });
                     
                     ed.onChange.add(function(){checkform();});

                   },
         content_css : basedomain+'/mce-styles.css'
      });
}

